package com.dhj.streamTest;

import com.dhj.streamTest.entity.Author;

import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;

import static com.dhj.streamTest.entity.AuthorList.getAuthors;

public class Demo4 {

    public static void main(String[] args) {
        List<Author> authors = getAuthors();

        authors.stream().map(new Function<Author, String>() {
            @Override
            public String apply(Author author) {
                return author.getName();
            }
        }).forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });

        System.out.println("================");

        authors.stream().map(obj -> obj.getName()).forEach(obj-> System.out.println(obj));


        System.out.println("================");

        authors.stream().map(author -> author.getAge()).map(age -> age+12).forEach(age-> System.out.println(age));

    }
}
